package com.cenntro.auth.model.vo;

import java.util.Date;

import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class BaseVO {

	private String createUser;
	private String updateUser;
	private Date cdt;
	private Date udt;
	
	
	public String getCreateUser() {
		return createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
		if (StringUtils.isBlank(this.createUser)){
			Subject subject = SecurityUtils.getSubject();
			if(subject != null  && subject.getSession() != null){
				Object obj = subject.getSession().getAttribute("userName");
				if (obj != null){
					this.createUser = obj.toString();
				}
			}
		}
	}
	public Date getCdt() {
		return cdt;
	}
	public void setCdt(Date cdt) {
		this.cdt = cdt;
		this.cdt = (this.cdt == null ? new Date() : this.cdt);
	} 
	
	
}
